#include "dialog.h"
#include <QPushButton>
#include <QLabel>
#include <QVBoxLayout>

dialog::dialog(QWidget *parent): QDialog(parent)
{
    QPushButton *button = new QPushButton("关闭");
    QLabel *label = new QLabel("hello QDialog");
    label->setAlignment(Qt::AlignCenter);

    QVBoxLayout *layout = new QVBoxLayout(this);
    this->setLayout(layout);

    layout->addWidget(label);
    layout->addWidget(button);

    //为按钮绑定信号槽
    connect(button,&QPushButton::clicked,this,&QDialog::close);
}
